import MsuiDataGridItemModel from './msui-datagrid-item-model'

class MsuiDataGridModel {
  constructor({ dataModel, align = 'center', showTip = true } = {}) {
    this.initDataGridItem(dataModel, align, showTip)
  }
  initDataGridItem(dataModel, align, showTip) {
    this._options = []

    for (let key in dataModel) {
      this._options.push({
        label: dataModel[key],
        prop: key,
        align: align,
        showTip: showTip
      })
    }

    this._options.forEach((item) => {
      this[item.prop] = new MsuiDataGridItemModel(item)
    })
  }
  setWidth(width) {
    this._options.forEach((item) => {
      this[item.prop].setWidth(width)
    })
  }
}

export default MsuiDataGridModel
